#include "BubbleSort.h"
using namespace std;
BubbleSort::BubbleSort(long v[], long n)
{
    for (long i = 0; i < n; ++i)
        this -> array[i] = v[i];
}
void BubbleSort::sort(long n)
{
    bool ok = true;
	long aux;
	while (ok)
	{
		ok = false;
		for (long i = 0; i < n - 1; ++i)
			if (this -> array[i] > this -> array[i + 1])
			{
				ok = true;
				aux = this -> array[i];
				this -> array[i] = this -> array[i + 1];
				this -> array[i + 1] = aux;
			}
	}
}
double BubbleSort::getExecutionTime(long n)
{
    clock_t start, end;
    start = clock();
    this -> sort(n);
    end = clock();
    return (double)(end - start) / CLOCKS_PER_SEC;
}
bool BubbleSort::Check(long n)
{
    long i;
	bool  ok = true;
	for (i = 0; i < n - 1; ++i)
		if (this -> array[i] > this -> array[i + 1])
		{
			ok = false;
			break;
		}
	cout << "\t" << i;
	return ok;
}

